#pragma once                          
                                      
#include <fstream>                    
#include <iostream>                   
#include <cmath>                       
#include "../../include/detection.hpp"


class Depot_Detection
{

  public:
  int depot_flag = 0;
  int depot_num = 1;
  int detect_row = 0;
  void reset()
  {
    depot_num = 1;
  }
  void clear()
  {
    depot_flag = 0;
    depot_num = 0;
  }
  bool Detection(vector<PredictResult> predict)
  {
    static int confidence =0;
    static int lost_time = 18;
    
    for (uint16_t i = 0; i < predict.size(); i++)
    {
        if (predict[i].label == LABEL_TRACTOR  && predict[i].y >= detect_row && predict[i].x >= 80)
        {
            confidence++;
            lost_time = 18;
            if(confidence>=6)
            {
              depot_flag = 1;
              return true;  
            }
            
        }
    }
    if(lost_time)
    {
      lost_time--;
    }
    else
    {
      confidence = 0;
    }
    return false;
  }
};